//
//  BlackListCollectionViewCell.m
//  TQY
//
//  Created by 甘世清 on 2024/10/19.
//

#import "BlackListCollectionViewCell.h"

@implementation BlackListCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.masksToBounds = YES;
        [self SQ_UIViewForSelfView];
    }
    return self;
}
/// 添加ui
-(void)SQ_UIViewForSelfView
{
    self.contentView.layer.cornerRadius = 10;
    self.contentView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.headerView];
    [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
  
    UIImageView * bgImage = [[UIImageView alloc]init];
    bgImage.image = SQGetImage(@"矩形 1106");
    bgImage.contentMode = UIViewContentModeScaleAspectFill;
    bgImage.clipsToBounds = YES;
    [self.headerView addSubview:bgImage];
    [bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.headerView);
        make.bottom.equalTo(self.headerView.mas_bottom).offset(-40);
        make.height.mas_equalTo(90);
    }];
    
    UIView * bgView = [[UIView alloc]init];
    bgView.backgroundColor = SQHexColor(@"#000000", 0.4);
    bgView.layer.cornerRadius = 12;
    bgView.layer.masksToBounds = YES;
    [self.contentView addSubview:bgView];
    [self.contentView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(14);
        make.bottom.equalTo(bgImage.mas_bottom).offset(-24);
        make.height.mas_equalTo(14);
    }];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.nameLabel).insets(UIEdgeInsetsMake(-5, -5, -5, -5));
    }];
    [self.contentView addSubview:self.genderImage];
    [self.genderImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(14);
            make.left.equalTo(bgView.mas_right).offset(10);
        make.centerY.equalTo(bgView);
    }];
    
    [self.contentView addSubview:self.deleteBtn];
    [self.deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(40);
        make.bottom.equalTo(self.contentView.mas_bottom);
    }];
  
}
- (void)setModel:(PeopleModel *)model{
    _model = model;
    [self.headerView sd_setImageWithURL:SQURLImage(model.portrait) placeholderImage:SQGetImage(@"1")];
    self.nameLabel.text = model.name;
    if ([model.gender isEqualToString:@"2"]) {
        self.genderImage.image = SQGetImage(@"女");
    } else {
        self.genderImage.image = SQGetImage(@"男");
    }
    
}
 
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = FONT_MEDIUM(13);
        _nameLabel.textColor = UIColor.whiteColor;
        _nameLabel.backgroundColor = UIColor.clearColor;
        _nameLabel.numberOfLines = 0;
    }
    return _nameLabel;
}
 
- (UIImageView *)headerView{
    if (!_headerView) {
        _headerView = [[UIImageView alloc]init];
        _headerView.contentMode = UIViewContentModeScaleAspectFill;
        _headerView.clipsToBounds = YES;
        _headerView.layer.cornerRadius = 10;
        _headerView.layer.masksToBounds = YES;
    }
    return _headerView;
}

- (UIImageView *)genderImage{
    if (!_genderImage) {
        _genderImage = [[UIImageView alloc]init];
        _genderImage.image = SQGetImage(@"女");
    }
    return _genderImage;
}
- (SQCustomButton *)deleteBtn{
    if (!_deleteBtn) {
        _deleteBtn = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(0, 0) midmargin:0];
        _deleteBtn.text = SQNSLocalString(@"取消拉黑");
        _deleteBtn.backgroundColor = SQHexColor(@"#000000", 0.6);
        _deleteBtn.font = FONT_MEDIUM(14);
        _deleteBtn.textColor = UIColor.whiteColor;
    }
    return _deleteBtn;
}
@end
